<%---------- init page ----------%>
<%@ page 
	language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"
    import="com.cdshop.web.PageUtil"
%>
<jsp:useBean id="model" class="com.cdshop.mvc.RegisterPM" scope="request"/>
<%
	model.populate(pageContext);
%>
<%---------- show ----------%>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title></title>
  <%@ include file="../inc/default.jsp" %>
  <link type="text/css" rel="stylesheet" href="<%=request.getContextPath()%>/style/calendar.css"/>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery_simpleDatepicker_src.js"></script>
</head>
<body>
 <div id="container" style="display:inline-table;">
 	<div id="top_banner">
			<%  com.cdshop.entity.User user=PageUtil.loginUser(pageContext);
				if(user==null){%>
			<a href="javascript:HJS.login();void 0;" class="top_font">登录</a>
			<a href="javascript:HJS.register();void 0;" class="top_font">注册</a>
			<%}else{%>
			<span class="top_font">欢迎您 <%=user.getNickname() %></span>
			<a href="javascript:HJS.shoppingCart();void 0;" class="top_font">购物车   </a>
			<a href="javascript:HJS.profile();void 0;" class="top_font">个人情况    </a>
			<a href="javascript:HJS.logout();void 0;" class="top_font">退出</a>
			<%}%>
	</div>
	<%@ include file="../inc/head.jsp" %>
	<div id="content">
		<div align="center">
			<h1>用户注册</h1>
			<form id="regForm" action="registerAction.jsp" method="post" enctype="application/x-www-form-urlencoded">
			<table cellpadding="0" cellspacing="0" style="table-layout:auto;">
				<tr>
			      <td height="30" align="right">用户名：</td>
			      <td align="left">
			      	<input type="text" id="username" name="username" value="<%= PageUtil.string(model.getUsername())%>" style="width:150px;" maxlength="32"/>
			      </td>
			    </tr>
			    <tr>
			      <td>&#32;</td>
			      <td align="left" height="15">
			      	 <span id="usernameMsg" class="message" style="color:red;font-size:12px"></span>
			      </td>
			    </tr>
			    
			    <tr>
			      <td height="30" align="right">昵称：</td>
			      <td align="left"><input type="text" id="nickname" name="nickname" value="<%= PageUtil.string(model.getNickname())%>" style="width:150px;" maxlength="32"/></td>
			    </tr>
			    <tr>
			      <td>&#32;</td>
			      <td align="left" height="15">
			      	 <span id="nicknameMsg" class="message" style="color:red;font-size:12px"></span>
			      </td>
			    </tr>
			    
			    <tr>
			      <td height="30" align="right">密码：</td>
			      <td align="left"><input type="password" id="password" name="password" style="width:150px;" maxlength="32"/></td>
			    </tr>
			    <tr>
			      <td height="30" align="right">确认：</td>
			      <td align="left"><input type="password" id="cpassword" name="cpassword" style="width:150px;" maxlength="32"/></td>
			    </tr>
			    <tr>
			      <td>&#32;</td>
			      <td align="left" height="15">
			      	 <span id="passwordMsg" class="message" style="color:red;font-size:12px"></span>
			      </td>
			    </tr>
			    
			    <tr>
			      <td height="30" align="right">邮箱：</td>
			      <td align="left"><input type="text" id="email" name="email" value="<%= PageUtil.string(model.getEmail())%>" style="width:150px;" maxlength="32"/></td>
			    </tr>
			    <tr>
			      <td>&#32;</td>
			      <td align="left" height="15">
			      	 <span id="emailMsg" class="message" style="color:red;font-size:12px"></span>
			      </td>
			    </tr>
			    
			    <tr>
			      <td height="30" align="right">性别：</td>
			      <td align="left">
			      		<%if(model.getSex()==1){%>
			      			男:<input type="radio" name="sex" value="1" checked="checked"/>
			      			女:<input type="radio" name="sex" value="0"/>
			      		<%}else{%>
				      		男:<input type="radio" name="sex" value="1"/>
			      			女:<input type="radio" name="sex" value="0" checked="checked"/>
			      		<%} %>
			      </td>
			    </tr>
			    <tr>
			      <td>&#32;</td>
			      <td align="left" height="15">
			      	 <span id="sexMsg" class="message" style="color:red;font-size:12px"></span>
			      </td>
			    </tr>
			    
			    <tr>
			      <td height="30" align="right">生日：</td>
			      <td align="left">
			      	<input type="text" id="stringBirthday" name="stringBirthday" value="" readonly="readonly"/>
			      </td>
			    </tr>
			    <tr>
			      <td>&#32;</td>
			      <td align="left" height="15">
			      	 <span id="birthdayMsg" class="message" style="color:red;font-size:12px"></span>
			      </td>
			    </tr>
			    
			     <tr>
			      <td height="30" align="right">角色：</td>
			      <td align="left"><input type="text" style="width:150px;" maxlength="32" value="USER" disabled="disabled"/>
			      				   <input type="hidden" id="roles" name="roles" value="USER"/></td>
			    </tr>
			    <tr>
			      <td>&#32;</td>
			      <td align="left" height="15">
			      	 <span id="rolesMsg" class="message" style="color:red;font-size:12px"></span>
			      </td>
			    </tr>
				<tr>
					<td height="40" colspan="2" align="center">
					<input type="submit" value="注册"/>
					<input type="reset" value="重置"/>
					</td>
				</tr>
			</table>
			</form>
		</div>
	</div>
	<%@ include file="../inc/footer.jsp" %> 
</div>
<script type="text/javascript">
//<![CDATA[
var PJS={
	init:function(){
		jQuery("#stringBirthday").simpleDatepicker({ startyear: 1910, 
												endyear: 2010, 
												pattern:"yyyy年MM月dd日", 
												months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
												weeks:["日","一","二","三","四","五","六"],
												todayLbl:"今天",
												closeLbl:"关闭",
												x:150, 
												y:0 });
		jQuery("#regForm").unbind("submit").submit(function(){
			return GJS.validate(
					{to:"#username",at:"#usernameMsg",rules:[["required","用户名必须填写"],["unique","用户名已经注册","/page/registerValidate.jsp"]]},
					{to:"#nickname",at:"#nicknameMsg",rules:[["required","昵称必须填写"]]},
					{to:"#password",at:"#passwordMsg",rules:[["required","密码必须填写"],["same","二次密码输入不同","#cpassword"]]},
					{to:"#stringBirthday",at:"#birthdayMsg",rules:[["required","生日必须填写"]]},
					{to:"#email",at:"#emailMsg",rules:[["required","邮箱必须填写"],["email","邮箱格式错误"],["unique","邮箱已经注册","/page/registerValidate.jsp"]]});
			
		});
		jQuery("input:reset").click(function(){jQuery(".message").hide();});
		jQuery("#username").click(function(){jQuery("#usernameMsg").hide();});
		jQuery("#nickname").click(function(){jQuery("#nicknameMsg").hide();});
		jQuery("#password").click(function(){jQuery("#passwordMsg").hide();});
		jQuery("#email").click(function(){jQuery("#emailMsg").hide();});
		jQuery("#stringBirthday").click(function(){jQuery("#birthdayMsg").hide();});
	}
};
jQuery(PJS.init);
//]]>
</script>
</body>
</html>